/*
 * help.c
 *
 *  Created on: Sep 7, 2013
 *      Author: Joseph DeLong
 */

/*
 * HELP command function
 * parameter argc: Integer representing the number of command arguments passed in
 * parameter argv: Pointer to an array of character strings representing the specific command(s) the USER is requesting help for
 * returns 0 if all went well or another integer, depending on the appropriate error code
 */
int help(int argc, char *argv[6]) {
	int returnVal = 0, goodInput = 0, i;
	if(argc < 1 || strcmp(argv[0],"\0") == 0) {
		printf( "You have invoked the HELP command. For more specific help, type HELP [CMD],\nwhere [CMD] is the command you would like help for.\n\n"
				"COMMANDS:\t| Description\n"
				"________________|_______________________________________________________\n"
				"date\t\t| Display/Set the current system date\n"
				"exit\t\t| Exit the system\n"
				"ls\t\t| Display the contents of the Present Working Directory\n"
				"version\t\t| Display the current version of the OS\n"
				"\n" );
		goodInput = 1;
	}
	else {
		if(strncmp(argv[1],"carrot",6) == 0) {
			printf("This has something to do with getting on Appaloosa's good side. Maybe she will let you ride her?\n");
			goodInput = 1;
		}
		if(strncmp(argv[1],"clear",5) == 0) {
			printf("This command clears the screen.\n");
			goodInput = 1;
		}
		if(strncmp(argv[1],"date",4) == 0) {
			printf( "To show the current date, use date.\n"
					"To set the system date, use date -s YYYY MM DD.\n"
					"You can enter negative years, just in case you are in BC.\n"
					"Months must be between 1 and 12.\n"
					"Days must not exceed their respective months, leapyears are included.\n");
			goodInput = 1;
		}
		if(strncmp(argv[1],"exit",4) == 0) {
			printf("This command will exit the Appaloosa OS. Make sure you have saved your work before exiting.\n");
			goodInput = 1;
		}
		if(strncmp(argv[1], "help",4) == 0) {
			printf("Yes, this is the help command.\n");
			goodInput = 1;
		}
		if(strncmp(argv[1],"ls",2) == 0) {
			printf("This command displays the contents of the Current Directory.\n");
			goodInput = 1;
		}
		if(strncmp(argv[1],"version",7) == 0) {
			printf("This command shows the version and developer information for the current version of the Appaloosa OS.\n");
			goodInput = 1;
		}
		if(goodInput == 0) {
			printf("You have requested help for a non-existant command: %s\n",argv[1]);
			returnVal = -56712; //placeholder for error code return (if we are going to do this)
		}
	}
	return returnVal;
}
